--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit da201fb3b6f6e74881dd9ab78416fe8e19e379e2
Parents : 56da0e7
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Date : 2026-05-18T15:18:05+02:00
Added option to filter sys and notice events from RRC room history on load
Changes
2 files changed, 25 insertions(+), 5 deletions(-)
Diff
diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py
index 3e1b1ab..9a9a500 100644
--- a/nomadnet/NomadNetworkApp.py
+++ b/nomadnet/NomadNetworkApp.py
@@ -153,7 +153,7 @@ class NomadNetworkApp:
self.accept_invalid_stamps = False
self.rrc_history_per_room_cap = 500
-
+ self.rrc_filter_loaded_history = True
if not os.path.isdir(self.storagepath):
os.makedirs(self.storagepath)
@@ -909,12 +909,15 @@ class NomadNetworkApp:
if "rrc" in self.config:
for option in self.config["rrc"]:
if option == "history_per_room_cap":
- try:
- value = self.config["rrc"].as_int(option)
- except Exception:
- value = None
+ try: value = self.config["rrc"].as_int(option)
+ except Exception: value = None
if value is not None and value >= 0:
self.rrc_history_per_room_cap = value
+
+ if option == "filter_loaded_history":
+ try: value = self.config["rrc"].as_bool(option)
+ except Exception: value = True
+ self.rrc_filter_loaded_history = value
if "node" in self.config:
if not "enable_node" in self.config["node"]:
@@ -1240,6 +1243,11 @@ sanitize_names = yes
# in memory (full history).
history_per_room_cap = 500
+# You can choose whether to filter system
+# and notice events when room history is
+# loaded.
+filter_loaded_history = yes
+
[node]
# Whether to enable node hosting
diff --git a/nomadnet/RRC.py b/nomadnet/RRC.py
index 7c92db3..6cc28ab 100644
--- a/nomadnet/RRC.py
+++ b/nomadnet/RRC.py
@@ -626,6 +626,11 @@ class RRCHub:
return None
return v if v > 0 else None
+ def _filter_history(self):
+ try: v = getattr(self.manager.app, "rrc_filter_loaded_history", True)
+ except Exception: return True
+ return v
+
def _entry_for(self, msg):
return {
H_KIND: msg.kind,
@@ -704,9 +709,16 @@ class RRCHub:
if decode_error is not None:
self._log("history file for #"+room+" is corrupt, truncating to last "+str(len(window))+" valid messages: "+str(decode_error), RNS.LOG_ERROR)
msgs = []
+ filter_msgs = self._filter_history()
for e in window:
m = self._msg_from_entry(room, e)
if m is not None:
+ if filter_msgs:
+ should_filter = False
+ if m.kind == "system": should_filter = True
+ elif m.kind == "notice": should_filter = True
+ if should_filter: continue
+
msgs.append(m)
with self._lock:
self.messages[room] = msgs
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────